package com.atguigu.common.exception;


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;


public class GetAjaxHtml {




        public static String getAjaxContent(String url) throws Exception {
            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec("D:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe C:\\Users\\Administrator\\Desktop\\11\\s.js " + url);
            InputStream is = p.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            StringBuffer sbf = new StringBuffer();
            String tmp = "";
            while((tmp=br.readLine())!=null) {
                sbf.append(tmp + "\n");
            }
            return sbf.toString();
        }

        public static void main(String[] args) throws Exception {
            long start = System.currentTimeMillis();
            String result = getAjaxContent("http://www.baidu.com");
            System.out.println(result);
            long end = System.currentTimeMillis();
            System.out.println("===============耗时：" + (end - start) + "===============");
        }

    }
